package day1027.dem1.two;



/**
 * @program: fanxing
 * @description:
 * @author: 诸葛龙辰
 * @create: 2022-10-27 16:18
 **/
public class Two {
    public static void main(String[] args) throws Exception {

            //1.通过类名来获取
            Class  pigClass = Pig.class;
            //2.通过对象获取对应的class对象
            Pig R = new Pig();
            Class aClass = R.getClass();
            //3.通过类名的全路径获取
            Class aCLass1 = Class.forName("day1027.dem1.two.Pig");
         //这三个都是获取Dog类对应的反射类对象
            //class文件只会加载一次
            System.out.println(pigClass==aClass);
            System.out.println(pigClass==aCLass1);
            System.out.println(aClass==aCLass1);

        }
    }
    class Pig{
        private String name;
        private  Integer age;

        public void show(){
            System.out.println("show方法");
        }
    }

